clang-tidy: resolve bugprone-throwing-static-initialization#472
clang-tidy: resolve bugprone-throwing-static-initialization#472
clang-tidy: resolve bugprone-throwing-static-initialization#472Conversation
bbfe20c to
3c844a9
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #472 +/- ##
==========================================
+ Coverage 85.49% 85.58% +0.08%
==========================================
Files 142 142
Lines 3586 3601 +15
Branches 615 616 +1
==========================================
+ Hits 3066 3082 +16
+ Misses 311 310 -1
Partials 209 209
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 3 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
|
@phlexbot tidy-fix -* bugprone-throwing-static-initialization |
|
No automatic clang-tidy fixes were necessary. |
07b2261 to
fde2d7b
Compare
|
@phlexbot tidy-fix -* bugprone-throwing-static-initialization |
|
No automatic clang-tidy fixes were necessary. |
28c33b7 to
971666b
Compare
|
@copilot Please fix the |
a5dc634 to
1596018
Compare
clang-tidy fixesbugprone-throwing-static-initialization warnings from clang-tidy
There was a problem hiding this comment.
Pull request overview
This PR addresses clang-tidy’s bugprone-throwing-static-initialization warnings by removing or deferring non-trivial static initialization in a few translation units and tests.
Changes:
- Replaced
inline std::stringtest constants withconstexpr char const*and updated call sites to constructstd::stringwhere required. - Moved namespace-scope/static initializations to function-local statics (or fixtures) to avoid static initialization before
main(). - Refactored a ROOT leaf-list type mapping table from namespace scope into
setupWrite().
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
test/form/test_utils.hpp |
Uses constexpr C-string literals for test file/tree names and adjusts string concatenation/calls accordingly. |
test/data_cell_counting.cpp |
Defers _idq.hash initialization via a Catch2 fixture helper. |
phlex/model/data_layer_hierarchy.cpp |
Reworks unnamed-layer formatting helper to avoid non-local static initialization. |
phlex/core/detail/filter_impl.cpp |
Replaces namespace-scope statics with a helper function for output-only query defaults. |
form/root_storage/root_tbranch_write_container.cpp |
Moves the type-to-leaf-list map into setupWrite() as a function-local static. |
bugprone-throwing-static-initialization warnings from clang-tidyclang-tidy fixes and ruff docstring/import cleanup
clang-tidy fixes and ruff docstring/import cleanupbugprone-throwing-static-initialization warnings from clang-tidy
|
@copilot Please add/augment tests as necessary to resolve the coverage gaps introduced by this PR as reported at https://github.com/Framework-R-D/phlex/pull/472/checks?check_run_id=70336551759 |
Added two new tests in 2c39c2d:
Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
bugprone-throwing-static-initialization clang-tidy warningsclang-tidy: resolve bugprone-throwing-static-initialization
2d14746 to
4c607aa
Compare
4c607aa to
4b1ed51
Compare
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Framework-R-D/phlex/sessions/5501225a-2e96-449f-94e4-a1dc4a613a1c Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com>
…t is intentional Agent-Logs-Url: https://github.com/Framework-R-D/phlex/sessions/cb3139bb-776b-463b-8198-38267887c6a7 Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Framework-R-D/phlex/sessions/d1188b31-3b1a-484b-8300-701ba55a692a Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
4b1ed51 to
7b48c74
Compare
Namespace-scope statics with non-trivial constructors (e.g.
std::string,std::unordered_map) triggerbugprone-throwing-static-initializationbecause their constructors can throw beforemain(). The fix moves all such statics to function-local scope (guaranteed-lazy, exception-safe initialization).Changes
phlex/core/detail/filter_impl.cpp— Wrapsoutput_dummyandfor_output_only_queriesin a function returningproduct_queries const&. Also fixes a latent bug: the original return-by-value causeddata_map::input_products_to point to a destroyed temporary.phlex/model/data_layer_hierarchy.cpp— Movesunnamedintomaybe_name()as astatic std::string const.form/root_storage/root_tbranch_write_container.cpp— MovestypeNameToLeafListfrom namespace scope intosetupWrite(). Map remains non-constwithoperator[]access: an unmapped fundamental type produces an empty leaf list, which ROOT silently treats asFloat_t— this is intentional.scripts/clang_tidy_fixes_to_problems.py— Fixes ruffI001/D101/D103issues (import order, missing docstrings).test/filter_impl.cpp— Adds"Data map for output only"test exercisingdata_map(for_output_t)to cover the newfor_output_only()function.test/data_cell_counting.cpp— Adds"Data layer hierarchy with unnamed layer"test; a child with an empty layer name triggers themaybe_name("") → "(unnamed)"path via the destructor'sgraph_layout()call.